<?php
Session_start();
$sessionId = session_id();//得到sessionid
//添加团购页面
include("../common.inc.php");
InitGP(array("action")); //初始化变量全局返回
include("function_common.php");

$titlestr="添加商家信息";
//初始化对象
include(INC_PATH."/suppliers.class.php");
$sp=new SupplierClass();

if(empty($action)){
	
	//显示添加表单
	include("tpl/suppliers_add.htm");
}elseif ($action=="save"){
	InitGP(array("name","web","address","map","tel","operating_time","codebar","resolution","bus","brief","about","pwd")); //初始化变量全局返回
	if(!empty($name)){
		//上传图片处理
		require_once (INC_PATH.'/upload.class.php');
		$f = new Upload();
		$f->setThumb(0);//设置不生成缩微图
		$f->run('fileimg',1);
		$info=$f->getInfo();
		$imgdata=$info[0]['fullsavename'];//获取第一个上传图片反馈
		//处理数据
		$arrayinsert=array(
			"name"=> Char_cv($name),
			"web"=> Char_cv($web),
			"img"=> $imgdata ,
			"address"=> Char_cv($address),
			"map"=>Char_cv($map) ,
			"tel"=> Char_cv($tel),
			"operating_time"=> Char_cv($operating_time),
			"codebar"=> Char_cv($codebar),
			"resolution"=> GetNum($resolution),
			"bus"=> Char_cv($bus),
			"brief"=> Char_cv($brief),
			"about"=>HtmlReplace($about,-1),
			"pwd"=> Char_cv($pwd)
		);
		$info=$sp->add($arrayinsert);
		if(is_numeric($info)){
			showmsg("添加商家信息成功!","suppliers_list.php");//成功
		}else showmsg($info,"suppliers_add.php");//出错！
	}else showmsg("缺少商家名称参数","suppliers_add.php");//出错！
}


?>